package com.yanqu.road.server.cmd.player;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.assistant.AssistantSkinProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;

@Cmd(code = CrossProtocol.C_CROSS_SEE_OTHER_ASSISTANT, desc = "跨服查看其他玩家的小助手")
public class CrossSeeOtherPlayerAssistantCmd extends CrossCommand {
    private long otherPlayerId;
    private long otherPlayerServerId;
    private int topNum;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        AssistantSkinProto.SeeOtherAssistantReqMsg msg = AssistantSkinProto.SeeOtherAssistantReqMsg.parseFrom(packet.getBytes());
        otherPlayerId = msg.getPlayerId();
        otherPlayerServerId = msg.getServerId();
        topNum = msg.getTopDecorationsNum();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        AssistantSkinProto.CrossSeeOtherAssistantReqMsg.Builder reqMsg = AssistantSkinProto.CrossSeeOtherAssistantReqMsg.newBuilder();
        reqMsg.setOriginPlayerId(packet.getPlayerId());
        reqMsg.setOriginServerId(serverId);
        reqMsg.setSeePlayerId(otherPlayerId);
        reqMsg.setTopNum(topNum);
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_CROSS_SEE_ASSISTANT, reqMsg);
        MessageHelper.sendPacket(otherPlayerServerId, 0, message);
    }

    @Override
    public void sendData() {

    }
}
